package com.luhongzhe.data;

import com.luhongzhe.config.Config;

/**
 * @author 	luhongzhe
 * @email  	azhe0660@gmail.com
 * @date   	2011-6-23
 */

public class LPoint
{
	private double x;
	private double y;
	
	public LPoint(double x, double y)
	{
		this.x = x; 
		this.y = y;
	}
	
	public double getX()
	{
		return x;
	}
	
	public double getY()
	{
		return y;
	}
	
	public int getIntX()
	{
		return (int)x;
	}
	
	public int getIntY()
	{
		return (int)y;
	}
	
	public boolean isClose(LPoint point)
	{
		return isClose(point.x, point.y);
	}
	
	public boolean isClose(double x, double y)
	{
		return getDistance(x, y) < Config.POINT_DISTANCE_TOLERANCE;
	}
	
	public static double getDistance(LPoint p1, LPoint p2)
	{
		return getDistance(p1.getX(), p1.getY(), p2.getX(), p2.getY());
	}
	
	public static double getDistance(double x1, double y1, double x2, double y2)
	{
		return (double)Math.hypot((x2 - x1) , (y2 - y1));      
	}
	
	public double getDistance(double x, double y)
	{
		return getDistance(getX(), getY(), x, y);
	}
	
}
